package org.apache.servicecomb.fence.resource.userHair;


import org.apache.servicecomb.fence.api.resource.UserHair;
import org.apache.servicecomb.fence.api.resource.UserHairService;
import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@RestSchema(schemaId = "UserHairEndpoint", schemaInterface = UserHairService.class)
public class UserHairEndpoint implements UserHairService {

    @Autowired
    private UserHairMapper userHairMapper;

    @Override
    public int createUserHair(UserHair userHair) {
        return userHairMapper.insert(userHair);
    }

    @Override
    public int updateUserHair(int id, UserHair userHair) {
        userHair.setId(id);
        return userHairMapper.update(userHair);
    }

    @Override
    public int deleteUserHair(int id) {
        return userHairMapper.deleteById(id);
    }

    @Override
    public UserHair getUserHair(int id) {
        return userHairMapper.getById(id);
    }

    @Override
    public List<UserHair> getAllUserHair() {
        return userHairMapper.getAll();
    }

    @Override
    public List<UserHair> searchUserHair(String hairColor, String hairType, Long minHairCount) {
        return userHairMapper.search(hairColor, hairType, minHairCount);
    }

    @Override
    public UserHair getUserHairByUserName(String userName) {
        return userHairMapper.getByUserName(userName);
    }

    @Override
    public int updateHairCount(int id, long hairCount) {
        return userHairMapper.updateHairCount(id, hairCount);
    }

    @Override
    public int updateHairColor(int id, String hairColor) {
        return userHairMapper.updateHairColor(id, hairColor);
    }

    @Override
    public int updateHairType(int id, String hairType) {
        return userHairMapper.updateHairType(id, hairType);
    }
}